#include<iostream>
#include<cmath>
typedef long long ll;
using namespace std;
ll n,m,T,L,V;
struct car{
    ll d;
    ll v;
    ll a;
    double out;
    ll rec;
};
struct camera{
    ll address;
    ll able;
};
car st[100005];
camera model[100005];

int main(){
    ///freopen("detect.in","r",stdin);
    ///freopen("detect.out","w",stdout);
    cin>>T;
    for (int i=1;i<=T;i++){
        cin>>n>>m>>L>>V;
        ll cnt=0,overdrive=0,ans=0;
        for (int j=1;j<=n;j++){
            cin>>st[j].d>>st[j].v>>st[j].a;
            st[j].rec=0;
            if (st[j].a!=0)
                st[j].out=st[j].d+1.0*(V*V-st[j].v*st[j].v)/(2*st[j].a);
            else
                st[j].out=0;
        }
        for (int j=1;j<=m;j++){
            cin>>model[j].address;
            model[j].able=0;
            for (int k=1;k<=n;k++){
                if (st[k].a>0){
                    if (st[k].out<=model[j].address&&model[j].address>=st[k].d){
                        model[j].able++;
                        if (st[k].rec==0){
                            overdrive++;
                            cnt++;
                        }
                        st[k].rec=1;
                    }
                }
                else if (st[k].a<0){
                    if (st[k].out>=model[j].address&&model[j].address>=st[k].d){
                        model[j].able++;
                        if (st[k].rec==0){
                            overdrive++;
                            cnt++;
                        }
                        st[k].rec=1;
                    }
                }
                else{
                    if (st[k].v>V&&model[j].address>=st[k].d){
                        model[j].able++;
                        if (st[k].rec==0){
                            overdrive++;
                            cnt++;
                        }
                        st[k].rec=1;
                    }
                }
            }
            if (n-cnt>=0){
                ans++;
                n-=cnt;
                cnt=0;
            }
        }
        cout<<overdrive<<" "<<ans<<endl;
    }
    return 0;
}
